// pages/auth/index.js
/**
 * 当用户点击授权时获取用户的信息
 * 通过小程序中的绑定getUserInfo方法
 * 拿到用户信息后取出需要的信息
 * 通过wx-login获取用户token
 */
import { request } from "../../request/index";
import regeneratorRuntime from "../../lib/runtime/runtime";
import { wxLogin } from "../../utils/WxApi";
Page({
  async handleGetUserInfo(e) {
    const { encryptedData, iv, rawData, signature } = e.detail;
    const code = await wxLogin();
    const loginData = { encryptedData, iv, rawData, signature, code };
    const res = await request({
      url: "/users/wxlogin",
      data: loginData,
      methods: "post"
    });
    console.log(res);
  }
});
